<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <title>编辑文章</title>
    <%@ include file="/WEB-INF/commons/header.jsp" %>
    <link rel="stylesheet" href="${ctx}/editormd/css/editormd.css">
    <link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon"/>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <%@ include file="/WEB-INF/commons/navbar.jsp" %>
    <%@ include file="/WEB-INF/commons/menu.jsp" %>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <form action="${ctx}/news/sendNews" method="post">

                <div class="layui-inline">
                    <label class="layui-form-label">新闻标题:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="newsTitle" lay-verify="required|phone" autocomplete="on"
                               class="layui-input" placeholder="请输入标题" required>
                    </div>
                </div>
                <br>
                <div class="layui-inline">
                    <label class="layui-form-label">新闻作者:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="newsAuthor" lay-verify="required|phone" autocomplete="on"
                               class="layui-input" placeholder="请输入作者" required>
                    </div>
                </div>

                <div id="editormd">
                    <textarea style="display:none;" name="newsArticle"></textarea>
                </div>

                <div align="center">
                    <button type="submit" class="layui-btn">提交</button>
                    <button type="reset" class="layui-btn layui-btn-warm">重置</button>
                </div>
            </form>

        </div>
    </div>
</div>

<script src="${ctx}/editormd/jquery-3.3.1.min.js"></script>
<script src="${ctx}/editormd/editormd.js"></script>

<script src="${ctx}/static/layui/layui.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    <%--// editormd 配置--%>
    var editormd_Ins;
    $(function () {
        editormd_Ins = editormd("editormd", {
            width: "100%",
            height: 400,
            syncScrolling: "single",
            htmlDecode: "style,script,iframe",
            path: "${ctx}/editormd/lib/",
            saveHTMLToTextarea: true, //这个配置，方便post提交表单
            //开启图片上传
            imageUpload: true,
            imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
            imageUploadURL: "${ctx}/news/uploadImage",//图片接口


            /*指定需要显示的功能按钮*/
            toolbarIcons: function () {
                return ["undo", "redo", "|",
                    "bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|",
                    "h1","h2","h3","h4","h5","h6","|",
                    "list-ul", "list-ol", "hr", "|",
                    "link", "reference-link", "image", "code", "preformatted-text",
                    "code-block", "table", "datetime", "emoji", "html-entities", "pagebreak", "|",
                    "goto-line", "watch", "preview", "fullscreen", "clear", "search", "|",
                    //"help","info",
                    "releaseIcon", "index"]
            },

        });
    });


</script>

</body>
</html>
